﻿using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using QldtSdh.DAL.Models.Mapping;

namespace QldtSdh.DAL.Models
{
    public partial class CEMS4UG_DHKHContext : DbContext
    {
        static CEMS4UG_DHKHContext()
        {
            Database.SetInitializer<CEMS4UG_DHKHContext>(null);

        }

        public CEMS4UG_DHKHContext()
            : base("Name=CEMS4UG_DHKHContext")
        {
        }

        public CEMS4UG_DHKHContext(string connectionString)
            : base(connectionString)
        {
            this.Configuration.LazyLoadingEnabled = true;
        }

        public DbSet<AppUser> AppUserDbSet { get; set; }
        public DbSet<AppUser_Function> AppUser_FunctionDbSet { get; set; }

        public DbSet<CongDoanSanXuat> CongDoanSanXuatDbSet { get; set; }
        public DbSet<MaySanXuat> MaySanXuatDbSet { get; set; }
        public DbSet<BoPhanMay> BoPhanMayDbSet { get; set; }
        public DbSet<NhiemVuBaoTri> NhiemVuBaoTriDbSet { get; set; }
        public DbSet<LichBaoTri> LichBaoTriDbSet { get; set; }
        public DbSet<LichSuBaoTri> LichSuBaoTriDbSet { get; set; }
        public DbSet<ChiTietMay> ChiTietMayDbSet { get; set; }
        public DbSet<PhanCongBaoTri> PhanCongBaoTriDbSet { get; set; }

        public DbSet<NhatKyHoatDong> NhatKyHoatDongDbSet { get; set; }
        public DbSet<KeyValueConfig> KeyValueDbSet { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            System.Diagnostics.Debug.WriteLine("Bắt đầu tạo Model");
            modelBuilder.Configurations.Add(new AppUserMap());
            modelBuilder.Configurations.Add(new AppUser_FunctionMap());

            modelBuilder.Configurations.Add(new CongDoanSanXuatMap());
            modelBuilder.Configurations.Add(new MaySanXuatMap());
            modelBuilder.Configurations.Add(new BoPhanMayMap());
            modelBuilder.Configurations.Add(new NhiemVuBaoTriMap());
            modelBuilder.Configurations.Add(new ChiTietMayMap());
            modelBuilder.Configurations.Add(new LichBaoTriMap());
            modelBuilder.Configurations.Add(new LichSuBaoTriMap());
            modelBuilder.Configurations.Add(new PhanCongBaoTriMap());

            modelBuilder.Configurations.Add(new NhatKyHoatDongMap());
            modelBuilder.Configurations.Add(new KeyValueConfigMap());

            System.Diagnostics.Debug.WriteLine("Kết thúc tạo Model");
        }
    }
}
